package mbsl.commons;

import mbsl.commons.games.GameController;
import mbsl.commons.videos.VideoController;
import mbsl.extensions.Extension;
import mbsl.storage.DatabaseTableManipulator;
import mbsl.system.Core;
import mbsl.system.Logger;
import mbsl.system.TextProvider;

public class Commons implements Extension {
	public static final TextProvider tp = new TextProvider("mbsl/commons/text");
	private static final Logger logger = new Logger(Commons.class);
	
	@Override
	public void init(Core pCore) {
		DatabaseTableManipulator manipulator = pCore.getDatabase().getTableManipulator();
		
		if (!manipulator.exists("games") || !manipulator.exists("videos")) {
			logger.info("   Commons is generating tables");
			
			manipulator.addScript("mbsl/commons/mbsl_commons.sql");
			
			manipulator.commit();
		}

		pCore.getDatabase().addResource("mbsl/commons/lib/lib.hbm.xml");
	}

	@Override
	public void shutdown(Core pCore) {

	}

	@Override
	public void start(Core pCore) {
		new GameController(pCore.getMainController());
		new VideoController(pCore.getMainController());
	}
	
	public String[] loadAfter() {
		return null;
	}
}
